import http from '@/utils/http'

const BASE_URL = '/cakerun/storePerformanceSummary'

export interface StorePerformanceSummaryQuery {
  accountIds?: number[]
  shopIds?: number[]
  city?: string
  lastWeekStartDate: string
  lastWeekEndDate: string
  thisWeekStartDate: string
  thisWeekEndDate: string
  scoreDate1?: string
  scoreDate2?: string
}

export interface StorePerformanceSummaryResp {
  serialNumber: number
  shopName: string
  lastWeekOrderCount: number
  lastWeekRevenue: number
  thisWeekOrderCount: number
  thisWeekRevenue: number
  score630: number
  score707: number
  rosScore: number
  goodReviewCount: number
  badReviewCount: number
  goodReviewRate: number
  badReviewRate: number
  exposureCount: number
  visitCount: number
  purchaseCount: number
  exposureToVisitRate: number
  visitToPurchaseRate: number
  isTotal?: boolean
}

export function fetchStorePerformanceSummary(query: StorePerformanceSummaryQuery) {
  return http.get<PageRes<StorePerformanceSummaryResp[]>>(`${BASE_URL}/list`, query)
}

// 如有导出接口
export function exportStorePerformanceSummary(query: StorePerformanceSummaryQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
